package edu.pw.treegrid.client.report.view;

import java.util.List;

import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.tab.Tab;
import com.smartgwt.client.widgets.tab.TabSet;
import com.smartgwt.client.widgets.tree.TreeGrid;

import edu.pw.treegrid.client.report.model.ReportColumnDescriptionClient;
import edu.pw.treegrid.shared.ReportColumnDescription;

public class HelpWindow extends Window {
	private ListGrid columnsGrid;
	private TreeGrid helpTree;
	
	public HelpWindow(List<ReportColumnDescriptionClient> columns) {
		initWindow();
		initColumnsGrid(columns);
		//initHelpTree();
		//initTabs();
		this.addItem(this.columnsGrid);
	}

	private void initWindow() {
		this.setWidth100();  
		this.setHeight100();   
		this.setTitle("Pomoc");   
		this.setShowMinimizeButton(false);   
		this.setIsModal(true);   
		this.setShowModalMask(true);   
		this.centerInPage();
		this.setKeepInParentRect(true);
		this.setMembersMargin(5);
	}
/*
	private void initTabs() {
		final TabSet topTabSet = new TabSet();      
        topTabSet.setWidth100();   
        topTabSet.setHeight100();   
  
        Tab columnsTab = new Tab("Kolumny", "");
        columnsTab.setPane(this.columnsGrid);   
  
        Tab hierachyTab = new Tab("Lista pomocy", "");   
        hierachyTab.setPane(helpTree);   
  
        topTabSet.addTab(columnsTab);
        topTabSet.addTab(hierachyTab);
        
        this.addItem(topTabSet);
	}

	private void initHelpTree() {
		this.helpTree = new TreeGrid();
		this.helpTree.setShowFilterEditor(true);
	}
*/	
	private void initColumnsGrid(List<ReportColumnDescriptionClient> columns) {
		this.columnsGrid = new ListGrid();
		this.columnsGrid.setData(columns
				.toArray(new ReportColumnDescriptionClient[0]));

		ListGridField partNameField = new ListGridField(
				ReportColumnDescription.TITLE);
		partNameField.setWidth("20%");
		ListGridField img = new ListGridField(ReportColumnDescription.IMAGE_SRC);
		img.setWidth("10%");
		img.setType(ListGridFieldType.IMAGE);
		ListGridField format = new ListGridField(ReportColumnDescription.FORMAT);
		format.setWidth("20%");
		ListGridField description = new ListGridField(ReportColumnDescription.DESCRIPTION);
		description.setWidth("50%");
		
		this.columnsGrid.setFields(img, partNameField, format, description);
	}

}
